package com.web.kdl.service.createTable;

import org.springframework.stereotype.Component;

/**
 * @Author： shulibin
 * @Date： 2025/8/21 18:02
 * @Describe：
 */
@Component
public class StatusTable extends AbstractFlywheelTable{
    public StatusTable() {
        super(null,null, null, TableType.STATUS);
    }
    public StatusTable(String siteName,String matrixName, String flywheelName) {
        super(siteName,matrixName,flywheelName, TableType.STATUS);
    }

    @Override
    public String createTable() {
        String sql = String.format("CREATE TABLE IF NOT EXISTS `%s` (" +
                "`id` bigint NOT NULL AUTO_INCREMENT," +
                "`flywheel_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`sum_site` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`sub_site` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`status_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`status_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`status_byte_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL," +
                "`time` datetime DEFAULT NULL," +
                "PRIMARY KEY (`id`) USING BTREE," +
                "INDEX `idx_time_id`(`time` ASC, `id` DESC) USING BTREE," +
                "INDEX `idx_status_name_time_desc`(`status_name` ASC, `time` DESC) USING BTREE" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;", getTableName());
        return sql;
    }

    @Override
    public String deleteTable() {
        return String.format("DROP TABLE IF EXISTS `%s`", getTableName());
    }

    @Override
    public void insertData(Object data) {

    }
}
